﻿using MediatR;
using S.RBAC.Domain.Dto;
using S.RBAC.Infrastructure.Interface;
using S.RBAC.Read.Api.Application.Command.StaffCommand;

namespace S.RBAC.Read.Api.Application.CommandHandlers.StaffHandler
{
    public class StaffGetNameCommandHandler : IRequestHandler<StaffGetNameCommand, StaffInfo>
    {
        protected readonly IStaffRepository _staff;

        public StaffGetNameCommandHandler(IStaffRepository staff)
        {
            _staff = staff;
        }

        public async Task<StaffInfo> Handle(StaffGetNameCommand request, CancellationToken cancellationToken)
        {
            var info = await _staff.GetStaffInfo(t => t.StaffId == request.StaffId);

            return new StaffInfo { Name = info.StaffName };
        }
    }
}
